import turtle
import random

turtles = list()


def haiguishulie():
    global turtles
    turtle_color = ['red', 'yellow', 'green', 'brown', 'cyan', 'orange', 'purple', 'gold']
    for i in range(0, 8):
        new_turtle = turtle.Turtle()
        new_turtle.shape('turtle')
        # new_turtle.speed(random.randint(3, 8) + random.randint(0, 10) / 10)
        new_turtle.speed(4)
        new_turtle.pencolor(turtle_color[i])
        turtles.append(new_turtle)


def main():

    global turtles
    haiguishulie()
    winner = True
    finishline = 400
    for i in range(0, len(turtles)):
        turtles[i].penup()
        turtles[i].goto(-200, -20 * i)
        turtles[i].pendown()
    while winner:
        for i in range(0, len(turtles)):
            turtles[i].forward(random.randint(0, 10))
            xcor = turtles[i].xcor()
            if xcor >= finishline:
                winner = False
                winner_turtle_color = turtles[i].color()
                print('The winner is ', winner_turtle_color[0],'turtle')

    turtle.done()


main()
